package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.travel.model.Visit;
import com.eling.elcms.travel.service.IVisitManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class VisitController extends BaseFormController{
	@Autowired
	IVisitManager visitManager;
	
	@RequestMapping("/api/visit/query")
    @ResponseBody
    public List<Visit> query(@ModelAttribute Visit cond){
    	return visitManager.query(cond); 
    }
	
	@RequestMapping("/api/visit/save")
    @ResponseBody
    public Visit save(@ModelAttribute Visit visit) {
		return visitManager.save(visit);
    }
	
	@RequestMapping("/api/visit/{pkVisit}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkVisit) {
		visitManager.remove(pkVisit);
	    return new Msg("删除成功");
	}
}
